package com.milan.analysis.user.controller;

import com.milan.analysis.common.pojo.User;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * LoginController
 *
 * @author liaozhidan
 * @date 2017/3/12
 */
@Controller
public class LoginController {


    @RequestMapping(value = "/home")
    public String home(HttpServletRequest request, ModelMap model) throws Exception {
        return "home/index";
    }

    @RequestMapping(value = {"/", "/login"})
    public String login(HttpServletRequest request, ModelMap model) throws Exception {
        User user = (User) request.getSession().getAttribute("user");
        if (user == null) {
            return "login/index";
        } else {
            return "redirect:/home";
        }
    }
}
